package org.albino.evinreisi.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;


public abstract class AbstractDao  {

	
	private DriverManagerDataSource dataSource=null;
	private JdbcTemplate jdbcTemplate=null;
	
	
	public JdbcTemplate getJdbcTemplate(){
		
		if(jdbcTemplate != null){
			return jdbcTemplate;
		}else{
		
			if(dataSource == null){
				dataSource = new DriverManagerDataSource();
				dataSource.setDriverClassName("org.postgresql.Driver");
				dataSource.setUrl("jdbc:postgresql://localhost:5432/evinreisi");
				dataSource.setUsername("postgres");
				dataSource.setPassword("postgres");
			}
		
			return new JdbcTemplate(dataSource);
		}
		
	}
	
	
}
